package com.nuc6.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nuc6.commons.Result;
import com.nuc6.entity.InterviewArrangement;
import com.nuc6.entity.User;
import com.nuc6.service.InterviewArrangementService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zwp
 * @since 2024-01-22
 */
@RestController
@RequestMapping("/arrangement")
public class InterviewArrangementController {
    @Resource
    private InterviewArrangementService interviewArrangementService;
    @PostMapping("/save")
    public Result saveUser(@RequestBody InterviewArrangement interviewArrangement){
        interviewArrangementService.save(interviewArrangement);
        return Result.success();
    }
    @PutMapping("/update")
    public Result updateUser(@RequestBody InterviewArrangement interviewArrangement){
        interviewArrangementService.updateById(interviewArrangement);
        return Result.success();
    }
    @DeleteMapping("/del/{id}")
    public Result del(@PathVariable Integer id){
        interviewArrangementService.removeById(id);
        return Result.success();
    }
    @RequestMapping("/arrangeByPage")
    public Result listUserByPage(@RequestParam(defaultValue = "1") Integer pageNum,
                                 @RequestParam(defaultValue = "5") Integer pageSize,
                                 @RequestParam(defaultValue = "") String search){
        QueryWrapper<InterviewArrangement> query = Wrappers.query();
        if(StringUtils.hasText(search)){
            query.like("position",search);
        }
        Page<InterviewArrangement> page = interviewArrangementService.page(new Page<>(pageNum, pageSize),query);
        return Result.success(page);
    }

}
